﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="reg1.aspx.cs" Inherits="reg" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>会员注册</title>
    <link type="text/css" href="css/other.css" rel="stylesheet" />
    <script language="javascript" type="text/javascript">
        var checkemailflag = 1;//没注册
        function checkemail(value) {
            if (value != null && value != '') {
                if (value.length < 3) {
                    checkemailflag = 0;
                    alert('邮箱格式不正确!');
                    return false;
                } else if (value.length > 30) {
                    alert('邮箱过长!');
                    checkemailflag = 0;
                    return false;
                } else {
                    if (!EmailValidate(value)) {
                        checkemailflag = 0;
                        alert('邮箱格式不正确!');
                        return false;
                    }
                    jQuery.ajax({
                        url: "Ajax/MemberLogin.ashx",
                        data: { t: 'MailCheck', txtemail: value },
                        type: "POST",
                        success: function (data) {
                            if (data + '' == 'True' || data + '' == 'true') {
                                checkemailflag = 1;
                                return true;
                            } else {
                                checkemailflag = 0; 
                                return false;
                            }
                        }
                    });
                }
            }
            return true;
        } 
        var checkeusernameflag = 1; //没注册
        function checkusername(value) {
            if (value != null && value != '') {
                    jQuery.ajax({
                        url: "Ajax/MemberLogin.ashx",
                        data: { t: 'NicknameCheck', txtnickname: value },
                        type: "POST",
                        success: function (data) {
                            if (data + '' == 'True' || data + '' == 'true') {
                                checkeusernameflag = 1;
                                return true;
                            } else {
                                checkeusernameflag = 0;
                                return false;
                            }
                        }
                    });
                }
            return true;
        }
         function checkmobileReg() {
             if (jQuery('#mobileReg').val().length !=11) {
                document.getElementById('mobileRegp').className = "important";
                jQuery("#mobileRegSpan").html('必须输入有效邮箱地址');
                return;
            } else { 
                document.getElementById('Regemail').className = "";
                jQuery("#emailMessage").html('&nbsp;');
            }
        }
        function checkemailReg() {
             if (jQuery('#email').val().length < 3) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('必须输入有效邮箱地址');
                return;
            } else if (!EmailValidate(jQuery('#email').val())) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('请输入的邮箱格式错误');
                return;
            } else { 
                document.getElementById('Regemail').className = "";
                jQuery("#emailMessage").html('&nbsp;');
            }
        }
        function checkusernameReg() {
            if (jQuery('#email').val() == "") {
                document.getElementById('email').value = "请避免使用真实姓名，注册成功后不可修改";
                return;
            } else if (jQuery('#username').val() == "请避免使用真实姓名，注册成功后不可修改") {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else if (jQuery('#username').val().length < 2) {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else {
                document.getElementById('Reusernaem').className = "";
                jQuery("#usernamemeassage").html('&nbsp;');
            }
        }
        function checkPass() {
            if (jQuery('#userpass').val().length < 7) {
                document.getElementById('pass1').className = "p_red";
                jQuery("#qiang").html('弱');
                return;
            } else if (jQuery('#userpass').val().length < 13) {
                document.getElementById('pass2').className = "p_red";
                jQuery("#qiang").html('中');
                return;
            } else if (jQuery('#userpass').val().length < 21) {
                document.getElementById('pass3').className = "p_red";
                jQuery("#qiang").html('强');
                return;
            }
        } 
        function checkRePass() {
            if (jQuery('#userpass').val() != jQuery('#userpass2').val()) {
                document.getElementById('Reuserpass2').className = "important"; 
                return;
            } else {
                document.getElementById('Reuserpass2').className = ""; 
            }
        }
        function checkFrm() {
            checkemail(jQuery('#email').val());
            checkusername(jQuery('#username').val());
            if (jQuery('#email').val().length < 3) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('必须输入有效邮箱地址'); 
                return;
            } else if (!EmailValidate(jQuery('#email').val())) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('您输入的邮箱格式错误'); 
                return;
            } else if (jQuery('#username').val() == "请避免使用真实姓名，注册成功后不可修改") {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('您输入用户名');
                return;
            } else if (jQuery('#username').val().length < 2) { 
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('您输入用户名');  
                return;
            } else if (jQuery('#userpass').val().length < 6) {
                alert("密码长度过短!");
                return;
            }
            else if (jQuery('#userpass2').val() != jQuery('#userpass').val()) {
                alert("两次密码不一致!");
                return;
            }
            else if (jQuery('#checkcode').val().length < 4 || jQuery('#checkcode').val() == "请输入右边的字符") {
                alert("请输入验证码!");
                return;
            } 
            else { 
                if (checkemailflag == 0) {
                    alert('此邮箱已经注册过!');
                    return;
                } 
                if (checkeusernameflag == 0) {
                    alert('此用户名已经注册过!');
                    return;
                }
                if ($('#checkBox').attr('checked')) {   // do something
                    jQuery('form').attr("action", "Ajax/MemberLogin.ashx?t=add&checkcode=" + jQuery('#checkcode').val() + "&username=" + jQuery('#username').val() + "&userpass=" + jQuery('#userpass').val() + "&email=" + jQuery('#email').val()).submit();
                } else {
                    alert('您还没查看条款!');
                    return;
                }
            }
        }
        function EmailValidate(value) {
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            return myreg.test(value);
        }
        function validate(value) {
            var reg = new RegExp("^[A-Za-z0-9]+$");
            if (!reg.test(value)) {
                alert("请输入数字和26个英文字母组成的字符串!");
            }
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="reg_box">
            <h2 class="reg_t">
            </h2>
            <div class="reg_tab">
                <!--Tab-->
                <div id="tabs4">
                    <ul>
                        <li><a href="#tabs-1" title="">手机号注册</a></li>
                        <li><a href="#tabs-2" title="">邮箱注册</a></li>
                    </ul>
                    <div id="tabs_container">
                        <div id="tabs-1">
                            <dl class="reg_dl">
                                <dd>
                                    <p class="reg_n"> 手机号</p>
                                    <input type="text" class="regbox" maxlength="11"  value="请输入手机号"
                                        name="mobileReg" id="mobileReg" onfocus="this.value=''"
                                        onblur="checkmobileReg()" />  
                                    <p id="mobileRegp"> </p>
                                    <p class="reg_red"> <span id="mobileRegSpan">&nbsp;</span></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        确认码</p>
                                    <asp:TextBox ID="TextBox2" runat="server" CssClass="regbox2" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请输入右边的字符'}">请输入右边的字符</asp:TextBox>
                                    <span class="code">
                                        <img src="images/code.gif" /></span>
                                    <asp:Button ID="Button2" runat="server" Text="换一张" CssClass="look" />
                                    <p class="p_kb">
                                    </p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        验证码</p>
                                    <asp:TextBox ID="TextBox3" runat="server" CssClass="regbox3" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请输入接收到的验证码'}">请输入接收到的验证码</asp:TextBox>
                                    <asp:Button ID="Button3" runat="server" Text="点击获取验证码" CssClass="huoqu" />
                                    <p class="p_kb">
                                    </p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        用户名</p>
                                    <asp:TextBox ID="TextBox4" runat="server" CssClass="regbox" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请避免使用真实姓名，注册成功后不可修改'}">请避免使用真实姓名，注册成功后不可修改</asp:TextBox>
                                    <p class="important">
                                    </p>
                                    <p class="reg_red">
                                        请输入用户名</p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        密码</p>
                                    <asp:TextBox ID="TextBox5" runat="server" CssClass="regbox" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='6-20个字符，不能为汉字（区分大小写）'}">6-20个字符，不能为汉字（区分大小写）</asp:TextBox>
                                    <p class="reg_password">
                                     <span class="p_n">密码强度</span>
                                    <span class="p_red"></span>
                                    <span class="p_f"></span>
                                    <span class="p_f"></span>
                                    <b class="red_f">弱</b>
                                    </p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        确认密码</p>
                                    <asp:TextBox ID="TextBox6" runat="server" CssClass="regbox" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请再次输入密码'}">请再次输入密码</asp:TextBox>
                                    <p class="p_kb">
                                    </p>
                                </dd>
                                <dd>
                                    <asp:Button ID="Button1" runat="server" Text="立即注册" CssClass="regbtn" />
                                    <a href="" class="reg_a">已有账号？</a> <a href="login.aspx" class="reg_b">立即登录</a>
                                </dd>
                                <dd>
                                    <p class="reg_agree">
                                        <asp:CheckBox ID="CheckBox1" runat="server" />
                                        我已同意<a href="" class="reg_c">《彩票米米用户服务条款》</a>
                                    </p>
                                </dd>
                            </dl>
                        </div>
                        <div id="tabs-2">
                            <dl class="reg_dl">
                                <dd>
                                    <p class="reg_n">邮箱</p>
                                    <input type="text" class="regbox" maxlength="30"  value="请输入邮箱地址"
                                        name="email" id="email" onfocus="this.value=''"
                                        onblur="checkemailReg()" /> 
                                    <p  id="Regemail"></p>
                                    <p class="reg_red"> <span id="emailMessage">&nbsp;</span></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">用户名</p>
                                    <input type="text" class="regbox" onblur="checkusernameReg()" onfocus="this.value=''"
                                         name="username" id="username" value="请避免使用真实姓名，注册成功后不可修改"/>
                                    <p  id="Reusernaem"></p>
                                    <p class="reg_red"> <span id="usernamemeassage">&nbsp;</span></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">密码</p>
                                    <input   class="regbox"  placeholder="6-20字符，不能为汉字（区分大小写）" onblur="checkPass();"  
                                    name="userpass"  id="userpass" type="password" maxlength="20" />
                                    <p class="reg_password">
                                    <span class="p_n">密码强度</span>
                                    <span class="p_f" id="pass1"></span>
                                    <span class="p_f" id="pass2"></span>
                                    <span class="p_f" id="pass3"></span>
                                    <b class="red_f"><span id="qiang">&nbsp;</span></b>
                                    </p>
                                </dd>
                                <dd>
                                    <p class="reg_n">确认密码</p>
                                    <input   class="regbox" placeholder="请再次确认你上次输入的密码"  onblur="checkRePass()" 
                                    name="userpass2" id="userpass2" type="password" /> 
                                    <p id="Reuserpass2"></p>
                                    <p class="p_kb"></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        验证码</p>
                                    <input type="text" class="regbox2" maxlength="4"  value="请输入右边的字符"
                                        name="checkcode" id="checkcode" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请输入右边的字符'}" />  
                                    <span class="code">
                                    <a href=""><img src="/Ajax/vilcode.aspx" id="checkCode_img"  alt="" width="81" height="31"/></a>
                                    </span> 
                                    <p class="p_kb">
                                    </p>
                                </dd>
                                <dd> 
                                    <input type="button" onclick="javascript:checkFrm();" class="regbtn" value="立即注册"/> 
                                    <a href=login.aspx"" class="reg_a">已有账号？</a> <a href="login.aspx" class="reg_b">立即登录</a>
                                </dd>
                                <dd>
                                    <p class="reg_agree">
                                        <input type="checkbox" checked="checked" id="checkBox" />我已同意<a href="" class="reg_c">《彩票米米用户服务条款》</a>
                                    </p>
                                </dd>
                            </dl>
                        </div>
                    </div>
                </div>
                <!--Tab-->
            </div>
        </div>
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/tabulous.js"></script>
        <script type="text/javascript" src="js/js.js"></script>
    </div>
    </form>
</body>
</html>
